/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
/* Copyright (C) 2012 Zongyou Yao. All rights reserved.     */

#ifndef ARITH_H_INCLUDED
#define ARITH_H_INCLUDED

/**
 * Returns max(x, y).
 */
int arith_max(int x, int y);

/**
 * Returns min(x, y).
 */
int arith_min(int x, int y);

/**
 * Returns x / y, the maximum integer that does not exceed the real number z
 * such that z * y = x. Truncates toward left, e.g., arith_div(-13, 5) returns
 * -3. It is an unchecked runtime error for y = 0.
 */
int arith_div(int x, int y);

/**
 * Returns x - y * arith_div(x, y), e.g., arith_mod(-13, 5) returns 2.
 * It is a unchecked runtime error for y = 0.
 */
int arith_mod(int x, int y);

/**
 * Returns the least integer not less than the real quotient of x / y. It
 * is an unchecked runtime error for y = 0.
 */
int arith_ceiling(int x, int y);

/**
 * Returns the greatest integer not exceeding the real quotient of x / y. It is
 * an unchecked runtime error for y = 0.
 */
int arith_floor(int x, int y);

#endif
